package com.golookon.dao;

import java.util.ArrayList;
import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional
public class StateCityDaoImpl extends BaseDaoImpl implements StateCityDao {

	@Override
	public List<String> getAllStates() throws DataAccessException {
		@SuppressWarnings("unchecked")
		List<String> results = em.createNamedQuery("StateCity.findAllStates").getResultList();
		if (results == null) {
			results = new ArrayList<String>();
		}
		return results;
	}

	@Override
	public List<String> getCitiesByState(String state)
			throws DataAccessException {
		@SuppressWarnings("unchecked")
		List<String> results = em.createNamedQuery("StateCity.findCitiesByState").setParameter("state", state).getResultList();
		if (results == null) {
			results = new ArrayList<String>();
		}
		return results;
	}

}
